#include "unionrobcontrollerhmiinstance_global.h"
#include "unionrobcontrollerhmiinstance.h"

static UnionRobControllerHMIInstance* pInstance = nullptr;

short    PLU_RobControllerHMIInstanceCreate(){
    if(pInstance == nullptr) pInstance = new UnionRobControllerHMIInstance();
    return 0;
}
short    PLU_RobControllerHMIInstanceDelete(){
    if(pInstance != nullptr) delete pInstance;
    return 0;
}
QWidget* PLU_RobControllerHMIIInstanceUiRegesiter(){
    if(pInstance != nullptr){
        return pInstance->getUiHandle();
    }
    else{
        if(pInstance == nullptr)
            pInstance = new UnionRobControllerHMIInstance();
        return pInstance->getUiHandle();
    }
}

void TIMER_fasttimerloop(){
    if(pInstance != nullptr){
        pInstance->timer_FastTimerLoop();
    }
}
void TIMER_slowtimerloop(){
    if(pInstance != nullptr){
        pInstance->timer_SlowTimerLoop();
    }
}

void SLOTS_btnModeSelectedclicked_(short Mode){
    if(pInstance != nullptr){
        pInstance->slots_onbtnclicked_ModeSelected(Mode);
    }
}

bool SLOTS_btnvPowerClicked(){
    if(pInstance != nullptr)
        return pInstance->slots_onbtnclicked_vPower();
    else
        return 0;
}
bool SLOTS_btnESTOPClicked(){
    if(pInstance != nullptr)
        return pInstance->slots_onbtnclicked_ESTOP();
    else
        return 0;
}
void SLOTS_btnHomeClicked(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnclicked_Home();
}

void SLOTS_btnSettingClicked(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnclicked_Setting();
}
void SLOTS_btnEditClicked(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnclicked_Edit();
}
bool SLOTS_btnPauseClicked(){
    if(pInstance != nullptr)
        return pInstance->slots_onbtnclicked_Pause();
    else
        return 0;
}
bool SLOTS_btnRunClicked(){
    if(pInstance != nullptr)
        return pInstance->slots_onbtnclicked_Run();
    else
        return 0;
}
bool SLOTS_btnStopClicked(){
    if(pInstance != nullptr)
       return  pInstance->slots_onbtnclicked_Stop();
    else
        return 0;
}

void SLOTS_btnfn1Clicked(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnclicked_fn1();
}
void SLOTS_btnfn2Clicked(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnclicked_fn2();
}
void SLOTS_btnfn3Clicked(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnclicked_fn3();
}
void SLOTS_btnfn4Clicked(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnclicked_fn4();
}

void SLOTS_btnMainScriptStatusClicked(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnclicked_MainScriptStatus();
}
void SLOTS_btnSubScriptStatusClicked(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnclicked_SubScriptStatus();
}
void SLOTS_btnVisHmiClicked(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnclicked_VisHmi();
}

void SLOTS_btnCoordinateClicked(short& Coordinate,int& ToolId, int& WorkID){
    if(pInstance != nullptr)
        pInstance->slots_onbtnclicked_Coordinate(Coordinate, ToolId, WorkID);
}

void SLOTS_btnXPPressed(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnpressed_XP();
}
void SLOTS_btnYPPressed(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnpressed_YP();
}
void SLOTS_btnZPPressed(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnpressed_ZP();
}
void SLOTS_btnAPPressed(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnpressed_AP();
}
void SLOTS_btnBPPressed(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnpressed_BP();
}
void SLOTS_btnCPPressed(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnpressed_CP();
}
void SLOTS_btnXNPressed(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnpressed_XN();
}
void SLOTS_btnYNPressed(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnpressed_YN();
}
void SLOTS_btnZNPressed(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnpressed_ZN();
}
void SLOTS_btnANPressed(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnpressed_AN();
}
void SLOTS_btnBNPressed(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnpressed_BN();
}
void SLOTS_btnCNPressed(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnpressed_CN();
}

void SLOTS_btnE1PPressed(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnpressed_E1P();
}
void SLOTS_btnE2PPressed(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnpressed_E2P();
}
void SLOTS_btnE1NPressed(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnpressed_E1N();
}
void SLOTS_btnE2NPressed(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnpressed_E2N();
}

void SLOTS_btnXPReleased(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnreleased_XP();
}
void SLOTS_btnYPReleased(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnreleased_YP();
}
void SLOTS_btnZPReleased(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnreleased_ZP();
}
void SLOTS_btnAPReleased(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnreleased_AP();
}
void SLOTS_btnBPReleased(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnreleased_BP();
}
void SLOTS_btnCPReleased(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnreleased_CP();
}
void SLOTS_btnXNReleased(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnreleased_XN();
}
void SLOTS_btnYNReleased(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnreleased_YN();
}
void SLOTS_btnZNReleased(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnreleased_ZN();
}
void SLOTS_btnANReleased(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnreleased_AN();
}
void SLOTS_btnBNReleased(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnreleased_BN();
}
void SLOTS_btnCNReleased(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnreleased_CN();
}

void SLOTS_btnE1PReleased(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnreleased_E1P();
}
void SLOTS_btnE2PReleased(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnreleased_E2P();
}
void SLOTS_btnE1NReleased(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnreleased_E1N();
}
void SLOTS_btnE2NReleased(){
    if(pInstance != nullptr)
        pInstance->slots_onbtnreleased_E2N();
}

void SLOTS_btnMannualOverridePClicked(double& value){
    if(pInstance != nullptr)
        pInstance->slots_onbtnclicked_MannualOverrideP(value);
}
void SLOTS_btnProgramOverridePClicked(double& value){
    if(pInstance != nullptr)
        pInstance->slots_onbtnclicked_ProgramOverrideP(value);
}
void SLOTS_btnMannualOverrideNClicked(double& value){
    if(pInstance != nullptr)
        pInstance->slots_onbtnclicked_MannualOverrideN(value);
}
void SLOTS_btnProgramOverrideNClicked(double& value){
    if(pInstance != nullptr)
        pInstance->slots_onbtnclicked_ProgramOverrideN(value);
}

void MES_fromBackendMessageCommand(QByteArray Data){
    if(pInstance != nullptr)
        pInstance->message_fromBackendMessageCommand(Data);
}

void MES_toBackendMessage(QByteArray& Data){
    if(pInstance != nullptr)
        pInstance->message_toBackendMessage(Data);
}

